//
//  LGSportsEvaDetailCpetCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/8/11.
//

#import "LGSportsEvaDetailCpetCell.h"

@interface LGSportsEvaDetailCpetCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;

@end

@implementation LGSportsEvaDetailCpetCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.clipsToBounds = YES;
        self.contentView.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
        [self.contentView addSubview:self.baseView];
        [self.baseView addSubview:self.titleLabel];
        [self.baseView addSubview:self.contentLabel];
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(viewPix(16));
            make.right.equalTo(self.contentView).offset(-viewPix(16));
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.baseView).offset(viewPix(16));
            make.right.equalTo(self.baseView).offset(-viewPix(90));
            make.top.equalTo(self.baseView).offset(viewPix(4));
            make.bottom.equalTo(self.baseView).offset(-viewPix(4));
        }];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.baseView).offset(-viewPix(16));
            make.centerY.equalTo(self.baseView);
        }];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    NSString *unit = LGNSString(dataDic[@"unit"]);
    if(unit.length>0){
        self.titleLabel.text = [NSString stringWithFormat:@"%@(%@)",dataDic[@"title"],dataDic[@"unit"]];
    }else{
        self.titleLabel.text = [NSString stringWithFormat:@"%@",dataDic[@"title"]];
    }
    self.contentLabel.text = LGNSString(dataDic[@"result"]);
}


-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _titleLabel;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(13, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _contentLabel;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
